$OpenBSD: patch-platform_x11_x11_main_c,v 1.3 2017/05/05 14:02:51 sthen Exp $

add pledge(2) to mupdf-x11 and mupdf-x11-curl:
  - inet dns : with HAVE_CURL only
  - proc exec : opening an external browser on uri link

Index: platform/x11/x11_main.c
--- platform/x11/x11_main.c.orig
+++ platform/x11/x11_main.c
@@ -706,7 +706,6 @@ void onselreq(Window requestor, Atom selection, Atom t
 void winreloadpage(pdfapp_t *app)
 {
 	XEvent xev;
-	Display *dpy = XOpenDisplay(NULL);
 
 	xev.xclient.type = ClientMessage;
 	xev.xclient.serial = 0;
@@ -717,8 +716,7 @@ void winreloadpage(pdfapp_t *app)
 	xev.xclient.data.l[0] = 0;
 	xev.xclient.data.l[1] = 0;
 	xev.xclient.data.l[2] = 0;
-	XSendEvent(dpy, xwin, 0, 0, &xev);
-	XCloseDisplay(dpy);
+	XSendEvent(xdpy, xwin, 0, 0, &xev);
 }
 
 void winopenuri(pdfapp_t *app, char *buf)
@@ -898,6 +896,20 @@ int main(int argc, char **argv)
 	tmo_at.tv_sec = 0;
 	tmo_at.tv_usec = 0;
 	timeout = NULL;
+
+#ifdef HAVE_CURL
+	if (pledge("stdio rpath inet dns proc exec", NULL) == -1)
+	{
+		fprintf(stderr, "pledge: %s\n", strerror(errno));
+		exit(1);
+	}
+#else
+	if (pledge("stdio rpath proc exec", NULL) == -1)
+	{
+		fprintf(stderr, "pledge: %s\n", strerror(errno));
+		exit(1);
+	}
+#endif
 
 	if (bps)
 		pdfapp_open_progressive(&gapp, filename, 0, bps);
